# Maintainer: metab0t <metab0t@outlook.com>

_realname=chicken
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.4.0
pkgrel=1
pkgdesc='Feature rich R5RS Scheme compiler and interpreter (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://call-cc.org/'
msys2_references=(
  "cpe: cpe:/a:call-cc:chicken"
)
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=("https://code.call-cc.org/releases/$pkgver/${_realname}-$pkgver.tar.gz")
sha256sums=('3c5d4aa61c1167bf6d9bf9eaf891da7630ba9f5f3c15bf09515a7039bfcdec5f')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  if [[ $MINGW_PACKAGE_PREFIX != *-clang-* ]]; then
    CFLAGS+=" -Wno-incompatible-pointer-types"
  fi

  make PLATFORM=mingw-msys PREFIX="${MINGW_PREFIX}" C_COMPILER="${CC}" C_COMPILER_OPTIMIZATION_OPTIONS="${CFLAGS}"
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make PLATFORM=mingw-msys DESTDIR="${pkgdir}" PREFIX="${MINGW_PREFIX}" install
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
